
import bpy
from bpy.types import Operator
import 全局控制.Node.节点和插座基类.bl_节点基类 as 基类

class C_ops_手动执行(bpy.types.Operator):
	bl_idname = 'node.update_node_manual_execution'
	bl_label = '手动执行更新节点'
	bl_options = {'REGISTER', 'UNDO'}

	m_节点树ID名称 = bpy.props.StringProperty(name='节点树ID名称', default='')
	m_节点ID名称 = bpy.props.StringProperty(name='节点树ID名称', default='')

	m_Node = None
	def execute(self, context):
		self.use_transform = True
		
		node_group = bpy.data.node_groups[self.m_节点树ID名称]
		node = node_group.nodes[self.m_节点ID名称]
		
		if node :
			node.f_更新节点树()
		return {'FINISHED'}


class C_SceneNode_手动执行(基类.C_SN_基类):
	bl_dname = 'bl_node_物体域'
	bl_label = '手动执行'
	
	def init(self, context):
		super(C_SceneNode_手动执行, self).f_init(context)
		self.outputs.new('C_NodeSocket_bool', name='是否执行')

	def draw_buttons(self, context, layout):
		opera = layout.operator("node.update_node_manual_execution")
		opera.m_节点树ID名称 = self.id_data.name
		opera.m_节点ID名称 = self.name

	def f_update(self, 是否向下传递=False, input插座=None):
		self.outputs['是否执行'].f_setData(True)
		super(C_SceneNode_手动执行, self).f_update(是否向下传递, input插座)


class C_NODE_MENU_手动执行(bpy.types.Operator):
	bl_idname = 'node.global_node_manual_execution'
	bl_label = 'Add 手动执行'
	bl_options = {'REGISTER', 'UNDO'}

	def execute(operator, context):
		operator.use_transform = True
		bpy.ops.node.add_node(type='C_SceneNode_手动执行', use_transform=True)
		return {'FINISHED'}



classes = (
	C_ops_手动执行,

	C_SceneNode_手动执行,
	C_NODE_MENU_手动执行,
)




def register():
	for c in classes:
		bpy.utils.register_class(c)
		

def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)


